#coding=utf-8
__author__ = 'jy@cjlu.edu.cn'
from xml.etree import ElementTree as XmlTree
xmlstr="""<?xml version="1.0" encoding="utf-8"?>
<测试>
    <测试值>4</测试值>
    <小测试 id="1">
        <测试值>Python11</测试值>
    </小测试>
    <小测试 id="2">
        <caption>Zope</caption>
    </小测试>
</测试>
"""
if __name__=="__main__":
    root=XmlTree.fromstring(xmlstr)
    #注意中文需要补充一个u使得变成utf编码 即可
    print root.find(u'测试值').text
    print root.find(u'小测试/caption').text

    #import web
    #db = web.database(dbn='mssql', user='sa', pw='86836093', db='JWCDB',host='10.252.0.120',port=2433)
    #result=db.query('select * from d_keywords')
    #for a in result:
    #    print a.keyword
    import pymssql
    dbconn = pymssql.connect(host='192.168.0.123:2433', user='sa', password='86836093', database='JWCDB')
    cursor = dbconn.cursor()
    sql ="SELECT * FROM d_keywords"
    cursor.execute(sql)
    row = cursor.fetchone()
    while row:
        print "ID=%d, Name=%s"% (row[0], row[1])
        row = cursor.fetchone()